/**
 * Supplier 业务逻辑
 * @author zhangq
 * @date 2014-12-10
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Supplier;
import com.chnbst.bstyun.model.vo.SupplierVo;
import com.chnbst.bstyun.service.SupplierService;

@Transactional
@Service
public class SupplierServiceImpl extends BaseService implements SupplierService{

	//声明日志对象 logback
	private final static Logger logger = LoggerFactory.getLogger(SupplierServiceImpl.class);
	private final static String nameSpace = "com.chnbst.bstyun.mapper.SupplierMapper";

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Supplier selectSupplierBySupplierId(Integer supplierId) {
		return (Supplier) DaoHelper.query(nameSpace, "selectSupplierBySupplierId", supplierId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertSupplier(Supplier supplier) {
		return DaoHelper.insert(nameSpace, "insertSupplier", supplier);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateBySupplierId(Supplier supplier) {
		return DaoHelper.update(nameSpace, "updateBySupplierId", supplier);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public int selectSupplierCountByCondition(Map<String, Object> map) {
		return DaoHelper.count(nameSpace, "selectSupplierCountByCondition", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<SupplierVo> selectSupplierVoByCondition(Map<String, Object> map) {
		
		return (List<SupplierVo>)DaoHelper.list(nameSpace, "selectSupplierVoByCondition", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public SupplierVo selectSupplierVoBySupplierId(Integer supplierId) {
		return (SupplierVo)DaoHelper.query(nameSpace, "selectSupplierVoBySupplierId", supplierId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Supplier selectSupplierByUserId(Integer userId) {
		return (Supplier)DaoHelper.query(nameSpace, "selectSupplierByUserId", userId);
	}
}
